// SINGULARITY HTML5 GAME ENGINE
// -----------------------------
// Copyright(c) 2013 by Codenova.pl

define(['../Core', './Fade'], function (Core, Fade) {
    var Animation = function(objAnimation) {
        this.Callback = objAnimation.Callback;
        this.Element = objAnimation.Element;
        this.Duration = objAnimation.Duration;
        this.RemoveElement = objAnimation.RemoveElement;
        this.Type = objAnimation.Type;
    };

    var _Animation = function() {};

    _Animation.prototype = {
        Fade: function(obj) {
            return Fade(obj);
        }
    };

    Animation.prototype = {
        Create: function(objAnimation) {
            return new Animation(objAnimation);
        },

        Stop: function(callback) {
            // For this moment we just call a callback :)
            callback();
        },

        Trigger: function() {
            var animation;
            var self = this;

            // Check animation type
            switch(this.Type) {
                case 'fadeout':
                    animation = _Animation.prototype.Fade(this);
                    break;
                case 'fadein':
                    animation = _Animation.prototype.Fade(this);
                    break;
                default:
                    break;
            }

            // Start loop
            requestAnimationFrame(function() {
                animation.Trigger(self.Element);
            }, null);
        }
    };

    return Animation.prototype.Create;
});